﻿Option Explicit On ' Make sure all items are explicitly declared
Option Strict On ' Be Very Strict about things here!
Namespace ZuneCardr
    ''' <summary>Card</summary>
    ''' <author>Comentsys</author>
    ''' <version>1.0.0</version>
    ''' <created>15th February 2009</created>
    ''' <modified>23rd February 2009</modified>
    ''' <remarks>Card and Resources</remarks>
    Public Class Card

        ' Public Constants

        Public Const MIN_COVER As Integer = 1 ' Min Cover Index
        Public Const MAX_COVER As Integer = 10 ' Max Cover Index
        ' Zunes
        Public Const ZUNE_4 As String = "4GB"
        Public Const ZUNE_8 As String = "8GB"
        Public Const ZUNE_16 As String = "16GB"
        Public Const ZUNE_30 As String = "30GB"
        Public Const ZUNE_80 As String = "80GB"
        Public Const ZUNE_120 As String = "120GB"
        ' Visbility
        Public Const SHOW_AVATAR As String = "ShowAvatar"
        Public Const SHOW_BACKGROUND As String = "ShowBackground"
        Public Const SHOW_COVERS As String = "ShowCovers"
        Public Const SHOW_COVER_TEXT As String = "ShowCoverText"
        Public Const SHOW_PLAYS As String = "ShowPlays"
        Public Const SHOW_BADGES As String = "ShowBadges"
        Public Const SHOW_STATUS As String = "ShowStatus"
        Public Const SHOW_LAST_PLAYED As String = "ShowLastPlayed"
        Public Const SHOW_WEBLINK As String = "ShowWeblink"
        Public Const SHOW_ZUNE As String = "ShowZune"
        ' Theme
        Public Const RES_GRADIENT_START As String = "GradientStart"
        Public Const RES_GRADIENT_END As String = "GradientEnd"
        Public Const RES_FOREGROUND As String = "Foreground"
        Public Const RES_BACKGROUND As String = "Background"
        Public Const RES_BORDER As String = "Border"
        Public Const RES_SECTION_FOREGROUND As String = "SectionForeground"
        Public Const RES_SECTION_BACKGROUND As String = "SectionBackground"
        Public Const RES_ITEM_FOREGROUND As String = "ItemForeground"

        ' Private Constants

        Private Const RES_IMAGE As String = "Image"
        Private Const RES_TEXT As String = "Text"
        Private Const RES_LOGO As String = "Logo" ' Default Avatar
        ' Strings
        Private Const RES_TAG As String = "ZuneTag"
        Private Const RES_PLAYS As String = "Plays"
        Private Const RES_PLAYS_FULL As String = "PlaysFull"
        Private Const RES_BADGES As String = "Badges"
        Private Const RES_STATUS As String = "Status"
        Private Const RES_LAST_PLAYED As String = "LastPlayed"
        Private Const RES_WEBLINK As String = "Weblink"
        Private Const RES_LOCATION As String = "Location"
        Private Const RES_BIOGRAPHY As String = "Biography"
        Private Const RES_ZUNE As String = "Zune"
        ' Gradients
        Private Const RES_VERTICAL_GRADIENT As String = "VerticalGradient"
        Private Const RES_HORIZONTAL_GRADIENT As String = "HorizontalGradient"
        ' Images
        Private Const RES_AVATAR As String = "Avatar"
        Private Const RES_AVATAR_IMAGE As String = "AvatarImage"
        Private Const RES_BACKGROUND_IMAGE As String = "BackgroundImage"
        Private Const RES_COVER As String = "Cover"
        ' Colours
        Private Const RES_ZUNE_COLOUR As String = "ZuneColour"
        ' Sources
        Private Const SOURCE_FAVS As String = "Favourites"
        Private Const SOURCE_RECENT As String = "Recent"
        Private Const SOURCE_ARTIST As String = "Artists"
        Private Const SOURCE_BADGES As String = "Badges"
        Private Const SOURCE_ALL As String = "All"
        ' Cards
        Private Const CARD_SMALL As String = "Small Zune Card (250x135)"
        Private Const CARD_LARGE As String = "Large Zune Card (548x260)"
        Private Const CARD_ZUNE As String = "Zune Card for Zune (320x240)"
        Private Const CARD_MYZUNE As String = "My Zune Card (250x135)"
        Private Const CARD_GAMER As String = "Gamer Card (204x140)"
        Private Const CARD_BANNER As String = "Banner Card (342x68)"
        Private Const CARD_SIGNATURE As String = "Signature Card (340x20)"
        Private Const CARD_NXE As String = "NXE Card (300x135)"
        Private Const CARD_CUSTOM As String = "(Custom)"

        ' Private Members

        Private blnShowAvatar As Boolean = True ' Avatar
        Private dblFactor As Double = 1.0 ' Default
        Private _CurrentStyle As Card.CardStyle = CardStyle.SmallZuneCard
        Private _CustomTheme As New ZuneCardr.Theme ' Custom Theme
        Private _CurrentTheme As New ZuneCardr.Theme ' Current Theme
        Private _Current As Canvas ' Current Card
        ' Card Styles
        Private SmallCard As New Cards.SmallCard
        Private LargeCard As New Cards.LargeCard
        Private MyZuneCard As New Cards.MyCard
        Private ZuneCard As New Cards.ZuneCard
        Private GamerCard As New Cards.GamerCard
        Private BannerCard As New Cards.BannerCard
        Private SignatureCard As New Cards.SignatureCard
        Private NXECard As New Cards.NXECard
        Private CustomCard As New Cards.Custom
        ' Custom

        ' Public Members

        Public Enum CardStyle
            SmallZuneCard = 0
            LargeZuneCard = 1
            ZuneCardZune = 2
            MyZuneCard = 3
            GamerCard = 4
            BannerCard = 5
            SignatureCard = 6
            NXE = 7
            Custom = 99
        End Enum

        Public Enum CardSource
            Favourites = 0
            Recent = 1
            Artists = 2
            Badges = 3
            All = 4
        End Enum

        ' Private Methods

        ''' <summary>SetResource</summary>
        ''' <param name="Name">Resource Name</param>
        ''' <param name="Value">Resource Object</param>
        ''' <remarks>Helper Function</remarks>
        Private Sub SetResource(ByVal Name As String, ByVal Value As Object)
            Application.Current.Resources.Item(Name) = Value ' Assign Resource
        End Sub

        ''' <summary>GetResource</summary>
        ''' <param name="Name">Resource Name</param>
        ''' <returns>Resource Contents</returns>
        ''' <remarks>Helper Function</remarks>
        Private Function GetResource(ByVal Name As String) As Object
            Return Application.Current.Resources.Item(Name) ' Get Resource
        End Function

        ''' <summary>GetVisibility</summary>
        ''' <param name="Value">Value to Check</param>
        ''' <returns>True if Visible, False if Otherwise</returns>
        ''' <remarks>Helper Function</remarks>
        Private Function GetVisibility(ByVal Value As Visibility) As Boolean
            Return Value = Visibility.Visible ' Visiblity to Boolean
        End Function

        ''' <summary>SetVisibility</summary>
        ''' <param name="Value">Value to Check</param>
        ''' <returns>Visible if True, Hidden if False</returns>
        ''' <remarks>Helper Function</remarks>
        Private Function SetVisibility(ByVal Value As Boolean) As Visibility
            Return CType(IIf(Value, Visibility.Visible, Visibility.Hidden), Visibility) ' Boolean to Visiblity
        End Function

        ''' <summary>GetTheme</summary>
        ''' <returns>Theme Object</returns>
        ''' <remarks>Helper Function</remarks>
        Private Function GetTheme() As Theme
            Dim Theme As New ZuneCardr.Theme
            Theme.GradientStart = CType(GetResource(RES_GRADIENT_START), Color)
            Theme.GradientEnd = CType(GetResource(RES_GRADIENT_END), Color)
            Theme.Background = CType(GetResource(RES_BACKGROUND), SolidColorBrush).Color
            Theme.Foreground = CType(GetResource(RES_FOREGROUND), SolidColorBrush).Color
            Theme.Border = CType(GetResource(RES_BORDER), SolidColorBrush).Color
            Theme.SectionBackground = CType(GetResource(RES_SECTION_BACKGROUND), SolidColorBrush).Color
            Theme.SectionForeground = CType(GetResource(RES_SECTION_FOREGROUND), SolidColorBrush).Color
            Theme.ItemForeground = CType(GetResource(RES_ITEM_FOREGROUND), SolidColorBrush).Color
            Return Theme
        End Function

        ''' <summary>SetGradients</summary>
        ''' <param name="GradientStart">Color</param>
        ''' <param name="GradientEnd">Color</param>
        ''' <remarks>Updates Gradients in Resources</remarks>
        Private Sub UpdateGradients(ByVal GradientStart As Color, ByVal GradientEnd As Color)
            Dim HorizontalGradient As New LinearGradientBrush
            Dim VerticalGradient As New LinearGradientBrush
            ' Horizontal
            HorizontalGradient.GradientStops.Add(New GradientStop(GradientStart, 0))
            HorizontalGradient.GradientStops.Add(New GradientStop(GradientEnd, 1))
            ' Vertical
            VerticalGradient.GradientStops.Add(New GradientStop(GradientEnd, 0))
            VerticalGradient.GradientStops.Add(New GradientStop(GradientStart, 1))
            ' Resources
            SetResource(RES_HORIZONTAL_GRADIENT, HorizontalGradient)
            SetResource(RES_VERTICAL_GRADIENT, VerticalGradient)
        End Sub

        ''' <summary>SetTheme</summary>
        ''' <param name="Theme">Theme Object</param>
        ''' <remarks>Helper Function</remarks>
        Private Sub SetTheme(ByRef Theme As ZuneCardr.Theme)
            UpdateGradients(Theme.GradientStart, Theme.GradientEnd) ' Gradients
            SetResource(RES_GRADIENT_START, Theme.GradientStart)
            SetResource(RES_GRADIENT_END, Theme.GradientEnd)
            SetResource(RES_BACKGROUND, New SolidColorBrush(Theme.Background))
            SetResource(RES_FOREGROUND, New SolidColorBrush(Theme.Foreground))
            SetResource(RES_BORDER, New SolidColorBrush(Theme.Border))
            SetResource(RES_SECTION_BACKGROUND, New SolidColorBrush(Theme.SectionBackground))
            SetResource(RES_SECTION_FOREGROUND, New SolidColorBrush(Theme.SectionForeground))
            SetResource(RES_ITEM_FOREGROUND, New SolidColorBrush(Theme.ItemForeground))
        End Sub

        ''' <summary>GetCard</summary>
        ''' <param name="Style"></param>
        ''' <returns>Card Canvas</returns>
        ''' <remarks>Helper Function</remarks>
        Private Function GetCard(ByVal Style As CardStyle) As Canvas
            _CurrentStyle = Style ' Curren Style
            Select Case Style
                Case CardStyle.LargeZuneCard
                    Return LargeCard
                Case CardStyle.ZuneCardZune
                    Return ZuneCard
                Case CardStyle.MyZuneCard
                    Return MyZuneCard
                Case CardStyle.GamerCard
                    Return GamerCard
                Case CardStyle.BannerCard
                    Return BannerCard
                Case CardStyle.SignatureCard
                    Return SignatureCard
                Case CardStyle.NXE
                    Return NXECard
                Case CardStyle.Custom
                    Return CustomCard.Canvas ' Custom
                Case Else
                    Return SmallCard
            End Select
        End Function

        ''' <summary>ImageStream</summary>
        ''' <param name="Encoder">Format</param>
        ''' <param name="Factor">Magnification</param>
        ''' <returns>Memory Stream</returns>
        ''' <remarks>Returns Memory Stream for Copy and Save</remarks>
        Private Function ImageStream(ByVal Encoder As BitmapEncoder, _
                              ByVal Factor As Double) As IO.MemoryStream
            Dim Output As New IO.MemoryStream ' Output
            Dim Source As Canvas = Current ' Source
            Dim Bmp As New System.Windows.Media.Imaging.RenderTargetBitmap(CInt(Source.Width * Factor), _
                                                               CInt(Source.Height * Factor), _
                                                               96 * Factor, 96 * Factor, _
                                                               System.Windows.Media.PixelFormats.Pbgra32)
            Source.Margin = New Thickness(0, 0, Source.Margin.Right - Source.Margin.Left, _
                                Source.Margin.Bottom - Source.Margin.Top) ' Correct Position
            Dim Size As New Size(Source.Width, Source.Height)
            Source.Measure(Size)
            Source.Arrange(New Rect(Size))
            Bmp.Render(Source)
            Encoder.Frames.Add(BitmapFrame.Create(Bmp))
            Encoder.Save(Output)
            Output.Seek(0, IO.SeekOrigin.Begin) ' Rewind
            Output.Close()
            Return Output
        End Function

        ' Public Methods

        ''' <summary>Custom</summary>
        ''' <param name="Filename">Filename</param>
        ''' <returns>Name</returns>
        ''' <remarks>Opens Custom Card XAML</remarks>
        Public Function Custom(ByVal Filename As String) As String
            CustomCard.Open(Filename)
            Return CustomCard.Name
        End Function

        ''' <summary>Layout</summary>
        ''' <param name="Source">Canvas</param>
        ''' <remarks>Re-Layouts Canvas</remarks>
        Public Sub Layout(ByRef Source As Canvas)
            Source.Margin = New Thickness(0, 0, Source.Margin.Right - Source.Margin.Left, _
                    Source.Margin.Bottom - Source.Margin.Top) ' Correct Position
            Dim Size As New Size(Source.Width, Source.Height)
            Source.Measure(Size)
            Source.Arrange(New Rect(Size))
        End Sub

        ''' <summary>Save</summary>
        ''' <param name="Filename">Filename of Image</param>
        ''' <remarks>Save Card to File</remarks>
        Public Sub Save(ByVal Filename As String)
            Dim SaveEncoder As BitmapEncoder = New System.Windows.Media.Imaging.PngBitmapEncoder()
            Dim Extension As String
            Extension = IO.Path.GetExtension(Filename) ' File Extension
            Select Case Extension.ToLower.Replace(".", "") ' Determine Encoder Type
                Case "jpg"
                    SaveEncoder = New System.Windows.Media.Imaging.JpegBitmapEncoder()
                Case "png"
                    SaveEncoder = New System.Windows.Media.Imaging.PngBitmapEncoder()
                Case "gif"
                    SaveEncoder = New System.Windows.Media.Imaging.GifBitmapEncoder()
                Case "bmp"
                    SaveEncoder = New System.Windows.Media.Imaging.BmpBitmapEncoder()
                Case "tif"
                    SaveEncoder = New System.Windows.Media.Imaging.TiffBitmapEncoder()
            End Select
            IO.File.WriteAllBytes(Filename, ImageStream(SaveEncoder, Factor).ToArray) ' Save
        End Sub

        ''' <summary>Copy</summary>
        ''' <remarks>Copy Card Image to Clipboard</remarks>
        Public Sub Copy()
            Dim CardImage As New BitmapImage
            CardImage.BeginInit()
            CardImage.StreamSource = New IO.MemoryStream(ImageStream(New PngBitmapEncoder, Factor).ToArray)
            CardImage.EndInit()
            Clipboard.SetImage(CardImage) ' Copy to Clipboard
        End Sub

        ''' <summary>Theme</summary>
        ''' <param name="Style">Theme Style</param>
        ''' <remarks>Gets / Sets the Theme</remarks>
        Public Sub Theme(ByVal Style As ZuneCardr.Theme.Style)
            CurrentTheme.Theme(Style)
            If Style = ZuneCardr.Theme.Style.Custom Then
                SetTheme(CustomTheme)
            Else
                SetTheme(CurrentTheme)
            End If
        End Sub

        ''' <summary>SourceList</summary>
        ''' <param name="ComboBox">ComboBox of Styles</param>
        ''' <remarks>Return List of Sources</remarks>
        Public Sub SourceList(ByRef ComboBox As ComboBox)
            ComboBox.Items.Clear()
            ComboBox.Items.Add(SOURCE_FAVS)
            ComboBox.Items.Add(SOURCE_RECENT)
            ComboBox.Items.Add(SOURCE_ARTIST)
            ComboBox.Items.Add(SOURCE_BADGES)
            ComboBox.Items.Add(SOURCE_ALL)
        End Sub

        ''' <summary>StyleList</summary>
        ''' <param name="ComboBox">ComboBox of Styles</param>
        ''' <remarks>Returns List of Styles</remarks>
        Public Sub StyleList(ByRef ComboBox As ComboBox)
            ComboBox.Items.Clear()
            ComboBox.Items.Add(CARD_SMALL)
            ComboBox.Items.Add(CARD_LARGE)
            ComboBox.Items.Add(CARD_ZUNE)
            ComboBox.Items.Add(CARD_MYZUNE)
            ComboBox.Items.Add(CARD_GAMER)
            ComboBox.Items.Add(CARD_NXE)
            ComboBox.Items.Add(CARD_BANNER)
            ComboBox.Items.Add(CARD_SIGNATURE)
            ComboBox.Items.Add(CARD_CUSTOM)
        End Sub

        ''' <summary>Source</summary>
        ''' <param name="Name"></param>
        ''' <returns>CardSource of Source</returns>
        ''' <remarks>Gets CardSource by Name</remarks>
        Public Function Source(ByVal Name As String) As CardSource
            Select Case Name
                Case SOURCE_FAVS
                    Return CardSource.Favourites
                Case SOURCE_RECENT
                    Return CardSource.Recent
                Case SOURCE_ARTIST
                    Return CardSource.Artists
                Case SOURCE_BADGES
                    Return CardSource.Badges
                Case SOURCE_ALL
                    Return CardSource.All
            End Select
        End Function

        ''' <summary>Style</summary>
        ''' <param name="Name">Style Name</param>
        ''' <returns>CardStyle of Style</returns>
        ''' <remarks>Gets CardStyle by Name</remarks>
        Public Function Style(ByVal Name As String) As CardStyle
            Select Case Name
                Case CARD_LARGE
                    Return CardStyle.LargeZuneCard
                Case CARD_ZUNE
                    Return CardStyle.ZuneCardZune
                Case CARD_MYZUNE
                    Return CardStyle.MyZuneCard
                Case CARD_GAMER
                    Return CardStyle.GamerCard
                Case CARD_NXE
                    Return CardStyle.NXE
                Case CARD_BANNER
                    Return CardStyle.BannerCard
                Case CARD_SIGNATURE
                    Return CardStyle.SignatureCard
                Case Else ' Custom & Small Card
                    If Name.Contains(CARD_CUSTOM) Then
                        Return CardStyle.Custom
                    Else ' Small Card
                        Return CardStyle.SmallZuneCard
                    End If
            End Select
        End Function

        ' Public Properties

        ''' <summary>Filename</summary>
        ''' <value>String</value>
        ''' <returns>Custom Filename</returns>
        ''' <remarks>Helper Property</remarks>
        Public ReadOnly Property Filename() As String
            Get
                Return CustomCard.Filename
            End Get
        End Property

        ''' <summary>Factor</summary>
        ''' <value>Double</value>
        ''' <returns>Native Factor Value</returns>
        ''' <remarks>Helper Property</remarks>
        Public ReadOnly Property Factor() As Double
            Get
                Return dblFactor
            End Get
        End Property

        ''' <summary>Output Size</summary>
        ''' <value>Integer</value>
        ''' <returns>Output Size</returns>
        ''' <remarks>Converts Percentage to Double</remarks>
        Public Property OutputSize() As Integer
            Get
                Return CInt(dblFactor * 100)
            End Get
            Set(ByVal Value As Integer)
                dblFactor = Value / 100
            End Set
        End Property

        ''' <summary>Current</summary>
        ''' <value>Canvas</value>
        ''' <returns>Current Card</returns>
        ''' <remarks>Get / Set Current Card</remarks>
        Public Property Current() As Canvas
            Get
                Return _Current
            End Get
            Set(ByVal Value As Canvas)
                _Current = Value
            End Set
        End Property

        ''' <summary>CurrentStyle</summary>
        ''' <value>CardStyle</value>
        ''' <remarks>Gets Current Style</remarks>
        Public ReadOnly Property CurrentStyle() As Card.CardStyle
            Get
                Return _CurrentStyle
            End Get
        End Property

        ''' <summary>CurrentTheme</summary>
        ''' <returns>Theme</returns>
        ''' <remarks>Get / Set Current Theme</remarks>
        Public Property CurrentTheme() As Theme
            Get
                Return _CurrentTheme
            End Get
            Set(ByVal Value As Theme)
                _CurrentTheme = Value
            End Set
        End Property

        ''' <summary>CustomTheme</summary>
        ''' <returns>Theme</returns>
        ''' <remarks>Get / Set Custom Theme</remarks>
        Public Property CustomTheme() As Theme
            Get
                Return _CustomTheme
            End Get
            Set(ByVal Value As Theme)
                _CustomTheme = Value
            End Set
        End Property

        ''' <summary>Card</summary>
        ''' <param name="Name">Style Name</param>
        ''' <returns>Card Canvas</returns>
        ''' <remarks>Returns the Zune Card Design</remarks>
        Public ReadOnly Property Card(ByVal Name As String) As Canvas
            Get
                Current = GetCard(Style(Name)) ' Set Current
                Return Current
            End Get
        End Property

        ''' <summary>Name</summary>
        ''' <param name="Style">Style</param>
        ''' <returns>String</returns>
        ''' <remarks>Card Name by Style</remarks>
        Public Function Name(ByVal Style As CardStyle, _
                             ByVal Custom As String) As String
            Select Case Style
                Case CardStyle.SmallZuneCard
                    Return CARD_SMALL
                Case CardStyle.LargeZuneCard
                    Return CARD_LARGE
                Case CardStyle.GamerCard
                    Return CARD_GAMER
                Case CardStyle.NXE
                    Return CARD_NXE
                Case CardStyle.ZuneCardZune
                    Return CARD_ZUNE
                Case CardStyle.MyZuneCard
                    Return CARD_MYZUNE
                Case CardStyle.BannerCard
                    Return CARD_BANNER
                Case CardStyle.SignatureCard
                    Return CARD_SIGNATURE
                Case CardStyle.Custom
                    Return Custom & CARD_CUSTOM
                Case Else
                    Return CARD_SMALL
            End Select
        End Function

        ''' <summary>Tag</summary>
        ''' <returns>Zune Tag</returns>
        ''' <remarks>Get / Set Zune Tag Resource</remarks>
        Public Property Tag() As String
            Get
                Return CStr(GetResource(RES_TAG))
            End Get
            Set(ByVal Value As String)
                SetResource(RES_TAG, Value)
            End Set
        End Property

        ''' <summary>Plays</summary>
        ''' <param name="Numeric">Numeric Only if True</param>
        ''' <returns>Plays</returns>
        ''' <remarks>Get / Set Plays Resource</remarks>
        Public Property Plays(ByVal Numeric As Boolean) As String
            Get
                If Numeric Then
                    Return CStr(GetResource(RES_PLAYS)) ' Numeric
                Else
                    Return CStr(GetResource(RES_PLAYS_FULL)) ' Full Plays
                End If
            End Get
            Set(ByVal Value As String)
                If Numeric Then
                    SetResource(RES_PLAYS, Value) ' Numeric
                Else
                    SetResource(RES_PLAYS_FULL, Value) ' Full Plays
                End If
            End Set
        End Property

        ''' <summary>Badges</summary>
        ''' <returns>Badges</returns>
        ''' <remarks>Get / Set Badges Resource</remarks>
        Public Property Badges() As String
            Get
                Return CStr(GetResource(RES_BADGES))
            End Get
            Set(ByVal Value As String)
                SetResource(RES_BADGES, Value)
            End Set
        End Property

        ''' <summary>Status</summary>
        ''' <returns>Status</returns>
        ''' <remarks>Get / Set Badges Resource</remarks>
        Public Property Status() As String
            Get
                Return CStr(GetResource(RES_STATUS))
            End Get
            Set(ByVal Value As String)
                SetResource(RES_STATUS, Value)
            End Set
        End Property

        ''' <summary>LastPlayed</summary>
        ''' <returns>LastPlayed</returns>
        ''' <remarks>Get / Set LastPlayed Resource</remarks>
        Public Property LastPlayed() As String
            Get
                Return CStr(GetResource(RES_LAST_PLAYED))
            End Get
            Set(ByVal Value As String)
                SetResource(RES_LAST_PLAYED, Value)
            End Set
        End Property

        ''' <summary>Weblink</summary>
        ''' <returns>Weblink</returns>
        ''' <remarks>Get / Set Weblink Resource</remarks>
        Public Property Weblink() As String
            Get
                Return CStr(GetResource(RES_WEBLINK))
            End Get
            Set(ByVal Value As String)
                SetResource(RES_WEBLINK, Value)
            End Set
        End Property

        ''' <summary>Location</summary>
        ''' <returns>Location</returns>
        ''' <remarks>Get / Set Location Resource</remarks>
        Public Property Location() As String
            Get
                Return CStr(GetResource(RES_LOCATION))
            End Get
            Set(ByVal Value As String)
                SetResource(RES_LOCATION, Value)
            End Set
        End Property

        ''' <summary>Biography</summary>
        ''' <returns>Biography</returns>
        ''' <remarks>Get / Set Biography Resource</remarks>
        Public Property Biography() As String
            Get
                Return CStr(GetResource(RES_BIOGRAPHY))
            End Get
            Set(ByVal Value As String)
                SetResource(RES_BIOGRAPHY, Value)
            End Set
        End Property

        ''' <summary>Zune</summary>
        ''' <returns>Zune</returns>
        ''' <remarks>Gets / Sets Zune</remarks>
        Public Property Zune() As String
            Get
                Return CStr(GetResource(RES_ZUNE))
            End Get
            Set(ByVal Value As String)
                SetResource(RES_ZUNE, Value)
            End Set
        End Property

        ''' <summary>ZuneColour</summary>
        ''' <returns>Zune Colour</returns>
        ''' <remarks>Gets / Sets Zune Colour (within SolidColorBrush)</remarks>
        Public Property ZuneColour() As Color
            Get
                Return CType(GetResource(RES_ZUNE_COLOUR), SolidColorBrush).Color
            End Get
            Set(ByVal Value As Color)
                SetResource(RES_ZUNE_COLOUR, New SolidColorBrush(Value))
            End Set
        End Property

        ''' <summary>AvatarImage</summary>
        ''' <returns>Avatar Image</returns>
        ''' <remarks>Gets/ Sets Avatar Image Resource</remarks>
        Public Property AvatarImage() As BitmapImage
            Get
                Return CType(GetResource(RES_AVATAR_IMAGE), BitmapImage)
            End Get
            Set(ByVal Value As BitmapImage)
                SetResource(RES_AVATAR_IMAGE, Value) ' Avatar Image
                SetResource(RES_AVATAR, Value) ' Backup Avatar Image
            End Set
        End Property

        ''' <summary>BackgroundImage</summary>
        ''' <returns>Background Image</returns>
        ''' <remarks>Gets/ Sets Background Image Resource</remarks>
        Public Property BackgroundImage() As BitmapImage
            Get
                Return CType(GetResource(RES_BACKGROUND_IMAGE), BitmapImage)
            End Get
            Set(ByVal Value As BitmapImage)
                SetResource(RES_BACKGROUND_IMAGE, Value)
            End Set
        End Property

        ''' <summary>CoverImage</summary>
        ''' <param name="Index">Index of Image</param>
        ''' <value>Value between 1-10</value>
        ''' <returns>Cover Image</returns>
        ''' <remarks>Gets / Sets Cover Image Resource by Index</remarks>
        Public Property CoverImage(ByVal Index As Integer) As BitmapImage
            Get ' Check if in Range
                If Index <= MAX_COVER And Index >= MIN_COVER Then
                    Return CType(GetResource(RES_COVER & RES_IMAGE & Index), BitmapImage)
                Else
                    Return Nothing
                End If
            End Get
            Set(ByVal Value As BitmapImage) ' Check if in Range
                If Index <= MAX_COVER And Index >= MIN_COVER Then
                    SetResource(RES_COVER & RES_IMAGE & Index, Value)
                End If
            End Set
        End Property

        ''' <summary>CoverText</summary>
        ''' <param name="Index">Index of Text</param>
        ''' <value>Value between 1-10</value>
        ''' <returns>Cover Text</returns>
        ''' <remarks>Gets / Sets Cover Text Resource by Index</remarks>
        Public Property CoverText(ByVal Index As Integer) As String
            Get ' Check if in Range
                If Index <= MAX_COVER And Index >= MIN_COVER Then
                    Return CStr(GetResource(RES_COVER & RES_TEXT & Index))
                Else
                    Return Nothing
                End If
            End Get
            Set(ByVal Value As String) ' Check if in Range
                If Index <= MAX_COVER And Index >= MIN_COVER Then
                    SetResource(RES_COVER & RES_TEXT & Index, Value)
                End If
            End Set
        End Property

        ''' <summary>ShowAvatar</summary>
        ''' <returns>Show Avatar</returns>
        ''' <remarks>Gets / Sets Show Avatar</remarks>
        Public Property ShowAvatar() As Boolean
            Get
                Return blnShowAvatar
            End Get
            Set(ByVal Value As Boolean)
                blnShowAvatar = Value
                If Value Then
                    SetResource(RES_AVATAR_IMAGE, GetResource(RES_AVATAR)) ' Show Avatar
                Else
                    SetResource(RES_AVATAR_IMAGE, GetResource(RES_LOGO)) ' Show Logo
                End If
            End Set
        End Property

        ''' <summary>ShowBackground</summary>
        ''' <returns>Show Background</returns>
        ''' <remarks>Gets / Sets Show Background</remarks>
        Public Property ShowBackground() As Boolean
            Get
                Return GetVisibility(CType(GetResource(SHOW_BACKGROUND), Visibility))
            End Get
            Set(ByVal Value As Boolean)
                SetResource(SHOW_BACKGROUND, SetVisibility(Value))
            End Set
        End Property

        ''' <summary>ShowCovers</summary>
        ''' <returns>Show Covers</returns>
        ''' <remarks>Gets / Sets Show Covers</remarks>
        Public Property ShowCovers() As Boolean
            Get
                Return GetVisibility(CType(GetResource(SHOW_COVERS), Visibility))
            End Get
            Set(ByVal Value As Boolean)
                SetResource(SHOW_COVERS, SetVisibility(Value))
            End Set
        End Property

        ''' <summary>ShowCoverText</summary>
        ''' <returns>Show Cover Text</returns>
        ''' <remarks>Gets / Sets Show Cover Text</remarks>
        Public Property ShowCoverText() As Boolean
            Get
                Return GetVisibility(CType(GetResource(SHOW_COVER_TEXT), Visibility))
            End Get
            Set(ByVal Value As Boolean)
                SetResource(SHOW_COVER_TEXT, SetVisibility(Value))
            End Set
        End Property

        ''' <summary>ShowPlays</summary>
        ''' <returns>Show Plays</returns>
        ''' <remarks>Gets / Sets Show Plays</remarks>
        Public Property ShowPlays() As Boolean
            Get
                Return GetVisibility(CType(GetResource(SHOW_PLAYS), Visibility))
            End Get
            Set(ByVal Value As Boolean)
                SetResource(SHOW_PLAYS, SetVisibility(Value))
            End Set
        End Property

        ''' <summary>ShowBadges</summary>
        ''' <returns>Show Badges</returns>
        ''' <remarks>Gets / Sets Show Badges</remarks>
        Public Property ShowBadges() As Boolean
            Get
                Return GetVisibility(CType(GetResource(SHOW_BADGES), Visibility))
            End Get
            Set(ByVal Value As Boolean)
                SetResource(SHOW_BADGES, SetVisibility(Value))
            End Set
        End Property

        ''' <summary>ShowStatus</summary>
        ''' <returns>Show Status</returns>
        ''' <remarks>Gets / Sets Show Status</remarks>
        Public Property ShowStatus() As Boolean
            Get
                Return GetVisibility(CType(GetResource(SHOW_STATUS), Visibility))
            End Get
            Set(ByVal Value As Boolean)
                SetResource(SHOW_STATUS, SetVisibility(Value))
            End Set
        End Property

        ''' <summary>ShowLastPlayed</summary>
        ''' <returns>Show Last Played</returns>
        ''' <remarks>Gets / Sets Show Last Played</remarks>
        Public Property ShowLastPlayed() As Boolean
            Get
                Return GetVisibility(CType(GetResource(SHOW_LAST_PLAYED), Visibility))
            End Get
            Set(ByVal Value As Boolean)
                SetResource(SHOW_LAST_PLAYED, SetVisibility(Value))
            End Set
        End Property

        ''' <summary>ShowWeblink</summary>
        ''' <returns>Show Weblink</returns>
        ''' <remarks>Gets / Sets Show Weblink</remarks>
        Public Property ShowWeblink() As Boolean
            Get
                Return GetVisibility(CType(GetResource(SHOW_WEBLINK), Visibility))
            End Get
            Set(ByVal Value As Boolean)
                SetResource(SHOW_WEBLINK, SetVisibility(Value))
            End Set
        End Property

        ''' <summary>ShowZune</summary>
        ''' <returns>Show Zune</returns>
        ''' <remarks>Gets / Sets Show Zune</remarks>
        Public Property ShowZune() As Boolean
            Get
                Return GetVisibility(CType(GetResource(SHOW_ZUNE), Visibility))
            End Get
            Set(ByVal Value As Boolean)
                SetResource(SHOW_ZUNE, SetVisibility(Value))
            End Set
        End Property

    End Class
End Namespace
